import Cookies from 'js-cookie'

function getExpires(h) {
  return new Date(new Date().getTime() + h * 60 * 60 * 1000); // 小时--管理端100
}

export function getCookie(key) {
  return Cookies.get(key)
}

export function setCookie(key, value) {
  // token\user\userRoleType\tid\md5_secretkey
  let expires = 'token' == key ? getExpires(72) : getExpires(900);
  // Cookies.set(key, value, {domain: 'localhost' == window.location.hostname ? 'localhost' : '.shisuiyun.com'})
  Cookies.set(key, value, {expires: expires, domain: 'localhost' == window.location.hostname ? 'localhost' : '.shisuiyun.com'});
  return;
}

export function removeCookie(key) {
  Cookies.remove(key);
  // Cookies.set(key, '', -1);
  // Cookies.set(key, '', {domain: 'localhost' == window.location.hostname ? 'localhost' : '.shisuiyun.com'});
  Cookies.remove(key, {domain: 'localhost' == window.location.hostname ? 'localhost' : '.shisuiyun.com'});
  return;
}
